package com.tools.commons.exceptions;

import com.tools.commons.response.ResponseCode;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * @author wangminggen
 */
@Getter
@Slf4j
public class CodingException extends RuntimeException {
    private final ResponseCode response;
    private final String[] args;

    public CodingException(ResponseCode response, String... args) {
        if (log.isDebugEnabled()) {
            log.debug("build a custom Exception => [ {} ]  template => [ {} ] args => [ {} ]", response, response.getDefaultMsgTemplate(), args);
        }
        this.response = response;
        this.args = args;
    }

    public CodingException(ResponseCode response) {
        this(response, (String) null);
    }

    public CodingException(String... args) {
        this(ResponseCode.BAD_REQUEST, args);
    }
}
